package com.tax.config.redisConfig.rediscondition;

import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @Description: 当配置value序列化类型为String时(未配置默认为string)
 * @Author wjd
 * @Date 2020/4/22 10:44
 **/
public class RedisStringCondition implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        Environment environment = conditionContext.getEnvironment();
        String type = environment.getProperty("redis.serializer.type", "string");
        if (StringUtils.equalsIgnoreCase("string", type)) {
            return true;
        }
        return false;
    }
}
